package com.jisf.driver.controller;

import com.jisf.driver.entity.po.StudentExamine;
import com.jisf.driver.entity.vo.ExamineStudentResponseVo;
import com.jisf.driver.response.Result;
import com.jisf.driver.response.ResultCode;
import com.jisf.driver.service.IStudentExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jisf
 * @since 2022-05-10
 */
@RestController
@RequestMapping("/driver/studentExamine")
public class StudentExamineController {

    @Autowired
    private IStudentExamineService iStudentExamineService;

    @GetMapping("appoint")
    @PreAuthorize("hasAnyAuthority('studentExamine:appoint')")
    public Result<?> appoint(@RequestParam Integer id){
        ResultCode resultCode = iStudentExamineService.appoint(id);
        return Result.ok(resultCode);
    }

    @GetMapping("cancel/appoint")
    @PreAuthorize("hasAnyAuthority('studentExamine:cancel:appoint')")
    public Result<?> cancelAppoint(@RequestParam Integer id){
        ResultCode resultCode = iStudentExamineService.cancelAppoint(id);
        return Result.ok(resultCode);
    }

    @GetMapping("student")
    @PreAuthorize("hasAnyAuthority('studentExamine:student')")
    public Result<?> getExamineStudent(@RequestParam Integer id){
        List<ExamineStudentResponseVo> examineStudent = iStudentExamineService.getExamineStudent(id);
        return Result.ok(examineStudent);
    }

    @PostMapping("setScore")
    @PreAuthorize("hasAnyAuthority('studentExamine:setScore')")
    public Result<?> setScore(@RequestBody StudentExamine studentExamine){
        ResultCode resultCode = iStudentExamineService.setScore(studentExamine);
        return Result.ok(resultCode);
    }

    @PostMapping("setRemark")
    @PreAuthorize("hasAnyAuthority('studentExamine:setRemark')")
    public Result<?> setRemark(@RequestBody StudentExamine studentExamine){
        ResultCode resultCode = iStudentExamineService.setRemark(studentExamine);
        return Result.ok(resultCode);
    }

}
